<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML>
<html>
  <head>
    <base href="<%=basePath%>">
    <title>班级编辑</title>
	<%@include file="../common/common.jsp" %>
    <script type="text/javascript" src="js/jquery.form.js"></script>
  </head>
  <body>
    <form id="frm" class="definewidth m20">
		<input type="hidden" name="action" value="${param.action }" />
		<input type="hidden" name="id" value="${param.id }" />
	    <table class="table table-bordered table-hover definewidth m10">
	        <tr>
	            <td width="17%" class="tableleft">学院</td>
	            <td>
	            	<select name="college" id="college" onchange="chkCollege(this)">
	            		<option value="">--选择学院--</option>
	            		<c:forEach var="college" items="${listCollege }">
	            			<option value="${college.id }" <c:if test="${param.college eq college.id }"> selected</c:if>>${college.name }
	            		</c:forEach>
	            	</select>
	            </td>
	        </tr>
	        <tr>
	            <td  class="tableleft">专业</td>
	            <td>
	            	<select name="professional" id="professional">
	            		<option value="">--选择专业--</option>
	            	</select>
	            </td>
	        </tr>
	        <tr>
	            <td class="tableleft">班级名称</td>
	            <td><input type="text" name="name" id="name" value="${info.name}"/></td>
	        </tr>
	        <tr>
	            <td class="tableleft"></td>
	            <td>
	                <button type="button" onclick="save()" class="btn btn-primary" type="button">保存</button>				 &nbsp;&nbsp;
	                <button type="button" class="btn" onclick="frameElement.api.close();">关闭</button>
	            </td>
	        </tr>
	    </table>
	</form>
  </body>
  <script type="text/javascript">
  	function save(){
  		var n=$("#name").val();
  		if(jQuery.trim(n)==''){
  			alert("请输入班级名称");
  			$("#name").focus()
  			return;
  		}
		var str=$('#frm').formSerialize();
    	$.post("class/save.do",str,function (a,b){
    		if(b=='success'){
    			var msg=a.msg;
    			alert(msg)
    			if(msg=='保存成功'){
    				window.location.href="<%=basePath%>class/query.do";
    			}
    		}
    	});
    }
    
    function chkCollege(op){
    	$.post("professional/queryjson.do",{collegeId:op.value},function (a,b){
    		if(b=='success'){
    			var list=a.list;
    			for(var i in list){
    				var l=list[i];
    				alert(l.name+"-	"+l.id)
    			}
    			alert(list);
    		}
    	});
    }
  </script>
</html>
